<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		
		<style>
			.red{
				color: red;
				font-family: "微软雅黑";
				font-size: 12px;
			}
			
			.green{
				color: green;
				font-family: "微软雅黑";
				font-size: 12px;
			}
			
			#usernameError{
				color: red;
				font-size: 12px;
				font-family: "微软雅黑";
			}
		</style>
	</head>
	<body>
		
		<form action="success.html">
			用户名<input name="username" type="text" > <span id="usernameError"></span>
			<br>
			
			家庭电话号码：<input name="telephone" type="text" > <span id="telephoneError"></span>
			
			
			<br>
			<input type="submit" value="提交" />
		</form>
	</body>
	<script type="text/javascript" src="../../js/jquery-1.4.1.js" ></script>
	<script>
		/**
		 *  用户名不能为空  长度最多为6位
		 */
		
		$("form").submit(function(){
			
			var str = $("input[name='username']").val();
			
			var result = str.match(/^[a-z]{1,6}$/);
			
			if(result == null){
				$("#usernameError").html("用户名不规范");
				return false;
			}
			console.log(result);
			return true;
			
		})
		
	</script>
</html>
